﻿
<?php
	
	@session_start();
	include('lib_db.php');
	/*****************code phần cart****************/
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title> BÁN SÁCH TRỰC TUYẾN </title>
		<link type="text/css" rel="stylesheet" href="css/style.css" />
		<link href="css/js-image-slider.css" rel="stylesheet" type="text/css"/>
		<script src="js/js-image-slider.js" type="text/javascript"></script>
		<script src="js/stickytooltip.js" type="text/javascript"></script>
		<link href="css/generic.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<div id ="wrapper">
			<div id ="header"><?php include("header.php");?></div><!--end header-->		
			<div id ="content">
				<div class="content-header"><?php include ("header-content.php")?></div> <!--end content-header-->
				
						<div class="clear-both"></div>			
				<div class="content-menu">
					<div class ="content-menu-left "><?php include ("content-menu-left.php")?></div>	<!--end content-menu-left -->				
					
					
						
						
							
					<div class ="giohang">
						<table  width='560'  border= '1'>
											<tr>
												<td>STT</td>
												<td>ảnh</td>
												<td>Tên</td>
												<td>Giá (VND)</td>
												<td>Số lượng</td>
												<td>Số lượng trong kho</td>
												<td>Tiền  </td>
												
											</tr>
								
							<?php
							//code phần giỏ hàng
							if(isset($_SESSION['giohang']))
							{ 	$tongsohang=0;
								for($i=0; $i<count($_SESSION['giohang']);$i++)
								{
									$query=("select * from book where idBook=".$_SESSION['giohang'][$i]['idBook']);
									$menu_left1 = select_list($query);
									
									?>
										
										
									<?php if($menu_left1) foreach ($menu_left1 as $row){?>
									
										<tr>	<?php $tientungmathang=($row['SalePrice']*$_SESSION['giohang'][$i]['soluong']);?>
												<td><?php echo ($i+1)?></td>
												<td> <img width="50px" height="50px" src="<?php  echo $row['ImgCover']?>"</td>
												<td><?php echo $row['Name']?></td>
												<td><?php echo $row['SalePrice']?></td>
												<td><input type= "text" name ="soluong" value ="<?php echo ($_SESSION['giohang'][$i]["soluong"])?>"</td>
												<td><?php if($tientungmathang>0){ echo number_format($tientungmathang*1, 0, ',', ' '); }?></td>
												<?php $tongsohang +=  ($_SESSION['giohang'][$i]["soluong"])?>
												

										</tr>
									
										
										
			
										<?php
												}
								} ?>

								<tr >
												<td>Tổng tiền:<?</td>
												<td><?php echo $_SESSION['tongtien']?></td>
												
												
								</tr>
							
							<?php } ?> 
										
							
							<?php 
							if(isset($tongsohang))
							{ ?>
							
								Trong giỏ hàng của bạn có <?php echo $tongsohang;?>  sản phẩm và tổng số tiền  <?php echo $_SESSION['tongtien'];?>VND <?php } ?>
						</table>
					<div class="giohang1">
						<div class="item"><a  href="#">Tiếp tục mua hàng</a></div>
						<div class="item"><a  href="#">Cập nhật số lượng</a></div>
						<div class="item"><a  href="#">Xóa giỏ hàng</a></div>
						<div class="item"><a  href="#">Mua và thanh toán</a></div>
					</div>
					</div>
					
					
					<div class ="content-menu-right"><?php include ("content-menu-right.php")?></div> <!--end content-menu-right-->
	
				</div> <!--end content-menu-->
			</div> <!--end content-->
			<div id ="footer"><?php include("footer.php");?></div><!--end footer-->
			
		
		</div><!--end wapper-->
	</body>
</html>